package com.zzy.sta.schedule;

import com.zzy.sta.service.StatisticsDailyService;
import com.zzy.sta.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.unit.DataUnit;

import java.util.Date;

/**
 * @Author KAZU
 * @Date 2023/1/27 8:22
 * @Version 1.0
 */
@SuppressWarnings({"all"})
@Component
public class ScheduledTask {
	
	@Autowired
	private StatisticsDailyService dailyService;
	
	/**
	 * 每天凌晨一点，把前一天的数据进行查询然后添加
	 * */
	@Scheduled(cron = "0 0 1 * * ?")
	public void task() {
		dailyService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
	}
	
	

	/**
	 * 测试
	 * 每天七点到二十三点每五秒执行一次
	 * */
//	@Scheduled(cron = "0/5 * * * * ?")
	public void task1() {
		System.out.println("...");
	}
	
}
